import { defineConfig, loadEnv } from "vite";
import { resolve } from "path";
import { setupVitePlugins } from "./build";

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const viteEnv = loadEnv(mode, process.cwd());
  return {
    plugins: setupVitePlugins(viteEnv),
    resolve: {
      alias: {
        "~": resolve(__dirname, "./"),
        "@": resolve(__dirname, "./src"),
      },
      extensions: [".json", ".js", ".jsx", ".ts", ".tsx", ".vue"],
    },
    server: {
      proxy: {
        "/api": {
          // target: "http://10.62.1.22:8080/api/pc",
          target: "http://localhost:8888",
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ""),
        },
      },
    },
  };
});
